package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IPatrolCompletionForManagerView;
import com.cloudsigns.factorymanager2.engineering.model.IPatrolCompletionForManagerModel;
import com.cloudsigns.factorymanager2.engineering.model.PatrolCompletionForManageModel;

/**
 * Created by tony on 2018/6/18.
 */

public class PatrolCompletionForManagePresenter {
    private IPatrolCompletionForManagerView view;
    private IPatrolCompletionForManagerModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public PatrolCompletionForManagePresenter(IPatrolCompletionForManagerView view) {
        this.view = view;
        this.model = new PatrolCompletionForManageModel();
    }

    public void patrolCompletionForManager() {


        model.patrolCompletionForManager(view.getOrderId(),
                new PatrolCompletionForManageModel.OnPatrolCompletionForManageListener() {
                    @Override
                    public void patrolCompletionForManageSunccessed() {
                        //需要在UI线程执行
                        mHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                view.patrolCompletionForManagerSuccess();
                                view.hideLoading();
                            }
                        });
                    }

                    @Override
                    public void patrolCompletionForManageFailed(final String desc) {
                        //需要在UI线程执行
                        mHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                view.patrolCompletionForManagerFailed(desc);
                                view.hideLoading();
                            }
                        });
                    }
                });

    }
}
